﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICUP13.Management;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using ICUP13.Texture;

namespace ICUP13.States
{
    public class MainMenuState : IBaseState
    {
        TextureManager tm = TextureManager.GetInstance();
        // Constructor
        public MainMenuState() { }

        // State Methods
        public override void Enter()
        {
        }
        public override void Exit()
        {
        }
        KeyboardState LastKeys = Keyboard.GetState();
        public override bool Input(float Delta, float TotalElapsed, int FPS)
        {
            KeyboardState CurrentKeys = Keyboard.GetState();

            if (CurrentKeys.IsKeyDown(Keys.Escape) && LastKeys.IsKeyUp(Keys.Escape))
                return false;
            else if (CurrentKeys.IsKeyDown(Keys.Enter) && LastKeys.IsKeyUp(Keys.Enter))
                StateMachine.AddStateQueue(new GamePlayState());
            LastKeys = CurrentKeys;
            return true;
        }
        public override void Update(float Delta, float TotalElapsed, int FPS)
        {

        }
        public override void Draw(float Delta, float TotalElapsed, int FPS)
        {
            clearScreen(TotalElapsed);
            MainGame.Batch.Draw(tm.MainMenuScreenBackground, MainGame.ClientRect, Color.White);
        }
        private void clearScreen(float TotalElapsed)
        {
            float rValue = (float)(1.0f - Math.Sin(TotalElapsed));
            float gValue = (float)(Math.Sin(TotalElapsed));
            float bValue = (float)(Math.Cos(TotalElapsed));
            MainGame.Device.Clear(new Color(rValue, gValue, bValue, 1f));
        }
    }
}
